<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=8" />
    <title>Python Exception Handling</title>

    <script src="../../js/jquery.js" type="text/javascript"></script>

    <script src="../../js/gestalt.js" type="text/javascript"></script>

</head>
<body>

<script language="python">
# imports
from System.Windows.Shapes import * # exposes Rectangle to scope since not added by default
from System.Diagnostics import * # enables outputing to a debug window!

# localize the XAML objects, so we keep the page footprint a tad smaller
grid = me.grid
button = me.button

# define the event handler for button MouseLeftButtonDown
def button_click(a,b):
    # do something silly that will throw an exception
    import sys
    try:
        x = 1 / 0 # create an error
    except:
        Debug.WriteLine(sys.exc_info())
    
    
# add an eventhandler for the button MouseLeftButtonDown event
# this must occur after the event handler is define above
button.Click += button_click


</script>

    <!-- This isn't a part of the sample, but a link back to the Gestalt site -->
    <div id="upsell" style="color:#fff; font-size: 13px; font-family:'Lucida Grande','Lucida Sans Unicode',Helvetica,Arial,Lucida,Verdana,sans-serif; margin-bottom: 30px;">
        <a href="http://www.visitmix.com/labs/gestalt/samples/" style="background-color: #000; color: #fff; display: block; text-decoration: none;" onmouseover="this.style.color='#000'; this.style.background='#ccc'" onmouseout="this.style.color='#fff'; this.style.background='#000'">
		    <span style="display:block; padding: 8px; text-align:center;">&laquo; Check out other samples on the Gestalt web site</span>
	    </a>
    </div>

    <xml id="TODO" class="xaml" width="300" height="100">
        <Grid x:Name="grid" Width="300" Height="100">
            <Button x:Name="button" Content="Click to write the error to debug window" Width="250" Height="25">
            </Button>
	    </Grid>
    </xml>
    
</body>
</html>
